﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Td.Additional.Environment
{
    /// <summary>
    /// Command line parameter meta data.
    /// </summary>
    public class CommandLineParameter
    {
        #region Properties

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public String Name { get; set; }
        /// <summary>
        /// Gets or sets the short name.
        /// </summary>
        /// <value>The short name.</value>
        public String ShortName { get; set; }
        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        public String Description { get; set; }
        /// <summary>
        /// Gets or sets the option.
        /// </summary>
        /// <value>The option.</value>
        public ParameterOption Option { get; set; }
        /// <summary>
        /// Gets or sets the value option.
        /// </summary>
        /// <value>The value option.</value>
        public ValueOption ValueOption { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [multiple values allowed].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [multiple values allowed]; otherwise, <c>false</c>.
        /// </value>
        public Boolean MultipleValuesAllowed { get; set; }
        /// <summary>
        /// Gets or sets the parameter type.
        /// </summary>
        /// <value>The parameter type.</value>
        public Type Type { get; set; }
        /// <summary>
        /// Gets or sets the default value.
        /// </summary>
        /// <value>The default value.</value>
        public Object DefaultValue { get; set; }
        /// <summary>
        /// Gets or sets the required parameters.
        /// </summary>
        /// <value>The required parameters.</value>
        public List<String> RequiredParameters { get; private set; }
        /// <summary>
        /// Gets or sets the found values.
        /// </summary>
        /// <value>The found values.</value>
        public int FoundValues { get; internal set; }

        #endregion

        #region Internal fields

        /// <summary>
        /// Gets or sets the name of the property.
        /// </summary>
        /// <value>The name of the property.</value>
        internal String PropertyName { get; set; }

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CommandLineParameter"/> class.
        /// </summary>
        public CommandLineParameter()
        {
            RequiredParameters = new List<string>();
            Option = ParameterOption.Optional;
            ValueOption = ValueOption.Optional;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Gets a value indicating whether this instance is valid.
        /// </summary>
        /// <value><c>true</c> if this instance is valid; otherwise, <c>false</c>.</value>
        public Boolean IsValid
        {
            get
            {
                if (DefaultValue != null && DefaultValue.GetType() != Type)
                    return false;
                return true;
            }
        }

        #endregion
    }
}